<?php
/*
 * @author Nguyen Xuan Hong
 * @copyright 2010
 */
session_start();
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<? if ($_GET['act'] == 'left') echo '<base target="frame_content">'; ?>
<title>Ngoi Nha Tre Tho - Administrator Control Panel</title>    

<link rel="stylesheet" type="text/css" href="../stylesheet/menu.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>


<script language="javascript" src="../javascript/jquery/jquery-1.4.3.min.js"></script>
<script language="javascript" src="../javascript/jqueryUI/jquery.ui.core.js"></script>
<script language="javascript" src="../javascript/jqueryUI/jquery.ui.widget.js"></script>  
<script language="javascript" src="../javascript/jqueryUI/jquery.ui.mouse.js"></script>  
 
<script language="javascript" src="../javascript/jqueryUI/jquery.ui.draggable.js"></script> 
<script language="javascript" src="../javascript/jqueryUI/jquery.ui.accordion.js"></script> 
<script language="javascript" src="../javascript/jqueryUI/jquery.ui.sortable.js"></script>

<script language="javascript" src="../javascript/jqueryUI/jquery.ui.datepicker.js"></script>

<!-- Service for select file on server -->
<script language="javascript" src="../javascript/jqueryExtend/jquery.FileTree.js"></script>
<!-- Service for tool upload file drag and drop -->
<script language="javascript" src="../javascript/jqueryExtend/jquery.upload-1.0.2.js"></script>
<!-- Service for tool upload select file -->
<script language="javascript" src="../javascript/jqueryExtend/jquery.ajaxfileupload.js"></script>
<!-- Service for data table -->
<script language="javascript" src="../javascript/jqueryExtend/jquery.dataTables.js"></script>


</style> 
</head>
<body>
	<?
	include('../includes/dbconfig.php');
	include('../includes/admincp.tbl.php');
	$pClsAdminCP = new clsAdminCPTable();

	if(!isset($_SESSION["admin"]))
	{
		if ($_REQUEST["mode"] != "login")
		{
			redirect("index.php?mode=login");
		}

		if (isset($_POST['username']))
		{
			$_SESSION["admin_username"] = $_POST["username"];
			$_SESSION["admin_password"] = $_POST["password"];
			include('../includes/admin.tbl.php');
			$pClsAdmin = new clsAdminTable();
			if ($pClsAdmin->login($_POST["username"],$_POST["password"]))
			{
				$_SESSION["admin"] = md5(time());
				redirect("index.php");
			}
			else
			{
				$fall_login_flag = true;
			}
		}

		echo $pClsAdminCP->putLoginForm($fall_login_flag);
		exit();
	}

	if (isset($_REQUEST["mode"]) && ($_REQUEST["mode"] == "login") )
	{
		if (isset($_SESSION["admin"]))
		{
			redirect("index.php");
		}
	}
	else if (isset($_REQUEST["mode"]) && ($_REQUEST["mode"] == "logout") )
	{
		$_SESSION["admin"] = "";
		unset($_SESSION["admin"]);
		redirect("index.php?mode=login");
	}
	?>
	<table width="100%">
		<tr width="100%">
			<td width="100%">
				<? include("head.php"); ?>
			</td>
		</tr>
		<tr width="100%">
			<td width="100%">
				<table width="100%">
					<tr width="100%">
						<td height="100%" width="250px" valign="top" bgcolor="#f3f3f3">
							<? include("leftframe.php"); ?>
						</td>
						<td height="100%" width="80%" valign="top" bgcolor="#fefefe">
							<? include("main.php"); ?>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>